#!/bin/sh
while [ $# -gt 0 ]; do
  gv="`cat $1 | sed -E -n 's/^([a-zA-Z0-9\-_]+[ \t]+.+;)$/extern \1/p' | sed -E 's/[ \t]=[ \t][^,;]+([,;])/\1/g'`"
  f="`cat $1 | sed -E -n 's/^([a-zA-Z0-9\-_]+[ \t]+[a-zA-Z0-9\-_ \t]*\**[a-zA-Z0-9\-_]+\(.+\))[ \t]+\{$/\1;/p'`"
  if test -n "$gv"; then
    echo "// global variables from $1"
    echo "$gv"
    echo
  fi
  if test -n "$f"; then
    echo "// functions from $1"
    echo "$f"
    echo
  fi
  shift
done

